<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>随机图片</title>
</head>
<body>
<!-- 小图 -->
<div style="background-color:red;border: dotted; height: 50px; width: 50px">
    <img src="" id="small" style="width: 50px; height: 50px;">
</div>
<!-- 大图 -->
<div style="border: double ;width: 400px; height: 400px; position: absolute; left: 500px; top:10px">
    <img src="" id="big" style="width: 400px; height: 400px; display:none;">
</div>

<!-- 开始和结束按钮 -->
<input id="startBtn" type="button" style="width: 150px;height: 150px; font-size: 20px" value="开始">
<input id="stopBtn" type="button" style="width: 150px;height: 150px; font-size: 20px" value="停止">
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    //准备一个数组
    let imgs = [
        "img/01.jpg",
        "img/02.jpg",
        "img/03.jpg",
        "img/04.jpg",
        "img/05.jpg",
        "img/06.jpg",
        "img/07.jpg",
        "img/08.jpg",
        "img/09.jpg",
        "img/10.jpg"];
    //计时器
    let time = null;
    //计数
    let count =0;
    //声明图片路径变量
    let imgSrc = "";
    //开始按钮
    $("#startBtn").click(function () {
        $("#startBtn").attr("disabled",true);
        $("#stopBtn").attr("disabled",false);
         time=setInterval(function () {
            let i = count % imgs.length;
            imgSrc=imgs[i];
            $("#small").attr("src",imgSrc);
            count++;
            },10)

    });
    //停止按钮
    $("#stopBtn").click(function () {
        clearInterval(time);
        $("#startBtn").attr("disabled",false);
        $("#stopBtn").attr("disabled",true);
        $("#big").attr("src",imgSrc);
        $("#big").attr("style","width: 400px; height: 400px;");
    });
</script>
</html>